import java.util.ArrayList;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-01-04
 * Time: 22:11
 */
public class CardList {

    public String[] suits;
    public  CardList(){
        suits=new String[]{"♥","♠","♦","♣"};
    }
    //买牌
    public ArrayList<Card> buyCard(){
        ArrayList<Card > cards=new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <=13; j++) {
                Card card=new Card(suits[i],j);
                cards.add(card);
            }
        }
        return cards;
    }
    //洗牌
    public void  washCard(ArrayList<Card> cards){
        Random random=new Random();
        for (int i = 51; i >0; i--) {
            int tmp=random.nextInt(i);
            swap( cards,i,tmp);

        }

    }
    private void swap(ArrayList<Card> cards,int i,int tmp){
        Card t=cards.get(i);
        cards.set(i,cards.get(tmp));
        cards.set(tmp,t);
    }
    //发牌
    public   void getCard(ArrayList<Card> cards,  ArrayList<ArrayList<Card>> hands){
        ArrayList<Card> hand1=new ArrayList<>();
        ArrayList<Card> hand2=new ArrayList<>();
        ArrayList<Card> hand3=new ArrayList<>();

        hands.add(hand1);
        hands.add(hand2);
        hands.add(hand3);
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < hands.size(); j++) {
                hands.get(j).add(cards.remove(0));
            }
        }

    }

}
